﻿Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim MCore As New Core.MetisCore("dam", "dam", "dam")
        Dim Func1 As New Metis.Core.Functions.MetisTableFunction(MCore)

        Func1.Name = "Tabelle1"
        Func1.Fields.Add(New Core.Functions.MetisFunctionField(Func1, -1, "Feld1", Core.Functions.MetisFunctionFieldType.KeyField))
        Func1.Fields.Add(New Core.Functions.MetisFunctionField(Func1, -1, "Feld2", Core.Functions.MetisFunctionFieldType.ValueField))
        Func1.Fields.Add(New Core.Functions.MetisFunctionField(Func1, -1, "Feld3", Core.Functions.MetisFunctionFieldType.ValueField))


        Dim Func2 As New Metis.Core.Functions.MetisTableFunction(MCore)
        Func2.Name = "OneTable"
        Func2.Fields.Add(New Core.Functions.MetisFunctionField(Func2, -1, "KeyField", Core.Functions.MetisFunctionFieldType.KeyField))
        Func2.Fields.Add(New Core.Functions.MetisFunctionField(Func2, -1, "ValueField", Core.Functions.MetisFunctionFieldType.ValueField))
        Func2.Fields.Add(New Core.Functions.MetisFunctionField(Func2, -1, "Feld3", Core.Functions.MetisFunctionFieldType.ValueField))


        Dim Func3 As New Metis.Core.Functions.MetisTableFunction(MCore)
        Func3.Name = "AnotherTable"
        Func3.Fields.Add(New Core.Functions.MetisFunctionField(Func3, -1, "PK", Core.Functions.MetisFunctionFieldType.KeyField))
        Func3.Fields.Add(New Core.Functions.MetisFunctionField(Func3, -1, "Feld2", Core.Functions.MetisFunctionFieldType.ValueField))
        Func3.Fields.Add(New Core.Functions.MetisFunctionField(Func3, -1, "Feld3", Core.Functions.MetisFunctionFieldType.ValueField))

        Dim tmpRefFunc1 = New Metis.Core.Functions.MetisRefFunction(MCore, Func1, Func2)
        Dim tmpRefFunc2 = New Metis.Core.Functions.MetisRefFunction(MCore, Func1, Func3, New System.Drawing.Point(160, 128))
        Func1.FunctionReferences.Add(tmpRefFunc1)
        Func1.FunctionReferences.Add(tmpRefFunc2)

        Func1.Joins.Add(New Metis.Core.Functions.MetisJoin(tmpRefFunc1, Func2.Fields(0), tmpRefFunc2, Func3.Fields(1), Func1))

        JoinDesigner1.Init(Func1)
    End Sub

    Private Sub JoinDesigner1_JoinClick(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles JoinDesigner1.JoinClick
        Debug.Print(e.Button.ToString & " Click")
    End Sub

    Private Sub JoinDesigner1_JoinDoubleClick(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles JoinDesigner1.JoinDoubleClick
        Debug.Print(e.Button.ToString & " DblClick")
    End Sub

    Private Sub TestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestToolStripMenuItem.Click
        JoinDesigner1.SelectedJoin.JoinType = Core.Functions.MetisJoinType.LeftJoin
    End Sub

    Private Sub Test2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test2ToolStripMenuItem.Click
        JoinDesigner1.SelectedJoin.JoinType = Core.Functions.MetisJoinType.InnerJoin
    End Sub

    Private Sub RightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightToolStripMenuItem.Click
        JoinDesigner1.SelectedJoin.JoinType = Core.Functions.MetisJoinType.RightJoin
    End Sub
End Class
